<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

//Route::group (['middleware'=>
//    [],'prefix'=>'admin','as'=>'admin.','namespace'=>'Admin'],function (){
//    Route::get ('/','HomeController@index')->name ('index');
//});

//后台Admin路由组
Route::group (['middleware'=> ['auth.admin'],'prefix'=>'admin','as'=>'admin.','namespace'=>'Admin'],function (){
    Route::get ('/','HomeController@index')->name ('home');
    Route::get('/config/edit/{name}','ConfigController@edit')->name('config.edit');
    Route::post('/config/update/{name}','ConfigController@update')->name('config.update');
    Route::resource('/column','ColumnController');

});

//前台Home路由组
Route::group (['namespace'=>'home'],function (){
    Route::get ('/','IndexController@index')->name ('index');
    Route::get('/login','LoginController@login')->name('login');
    Route::post('/login','LoginController@store')->name('login');
    Route::get('/logout','LoginController@logout')->name('logout');
    Route::resource('/user','UserController');
    Route::resource('article','ArticleController');
    Route::get('/zan/{article}','ArticleController@TogoZan')->name('TogoZan');
    Route::resource('/topic','TopicController');
});

//用户中心路由组
Route::group (['namespace'=>'Info','as'=>'info.','prefix'=>'info'],function (){
    Route::get ('/','UserController@index')->name ('index');
    Route::resource('user','UserController');
    Route::get('/ToggleFollower/{user}','UserController@ToggleFollower')->name('ToggleFollower');
  Route::get('/ReadNotify/{notification}','UserController@ReadNotify')->name('ReadNotify');

});
//工具类路由
Route::group(['namespace'=>'Util',],function (){
    Route::any('code/send','CodeController@send')->name('code.send');
    Route::any('upload/upload','UploadController@upload')->name('upload.upload');
    Route::any('upload/lists','UploadController@lists')->name('upload.lists');
});

//用户中心路由组
Route::group (['namespace'=>'Common','as'=>'common.','prefix'=>'common'],function (){
    Route::resource('common','CommentController');
    //收藏方法
    Route::get('/favorite/click','FavortieController@click')->name('favorite.click');
    Route::get('/zan/click','ZanController@click')->name('zan.click');
});
